package git.bankview.wl.report;

import java.util.*;
import java.text.*;
import java.io.*;

import laya.semi.process.*;
import git.bankview.sl.report.ReportCommon;
import git.bankview.sl.report.ReportParameter;

import git.bankview.sl.db.*;

import org.apache.log4j.Logger;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRLoader;

public class JasperObjectAnalyzer
	implements IGenericClassActivity
{
	private static Logger log = Logger.getLogger(JasperObjectAnalyzer.class);

	public void execute(IProcessContext oCtx)
		throws Exception
	{
		String[] params = oCtx.getActivityParameter().split(":");
		
		for (int i = 0; i < params.length; ++i)
		{
			Object obj = oCtx.getField(params[i]);
			if (null == obj)
				continue;
			
			if (obj.getClass().isArray())
			{
				Object[] v = (Object[])obj;
				for (int j = 0; j < v.length; ++j)
				{
					if (v[j] instanceof java.lang.String)
					{
						JRLoader.loadObject(new File((String)v[j]));
					}
					else if (v[j] instanceof java.io.File)
					{
						JRLoader.loadObject((File)v[j]);
					}
					else if (v[j] instanceof java.io.InputStream)
					{
						JRLoader.loadObject((InputStream)v[j]);
					}
					else
					{
						throw new ActivityException(oCtx, "jasperUpload.err.unknowType");
					}
				}
			}
			else if (obj instanceof java.lang.String)
			{
				JRLoader.loadObject(new File((String)obj));
			}
			else if (obj instanceof java.io.File)
			{
				JRLoader.loadObject((File)obj);
			}
			else if (obj instanceof java.io.InputStream)
			{
				JRLoader.loadObject((InputStream)obj);
			}
			else
			{
				throw new ActivityException(oCtx, "jasperUpload.err.unknowType");
			}
		}
	}
}
